<template>
	<view>
		<button type="default" @click="handleCfy">分类录入</button>
		<button type="default" @click="handleCGood">商品录入</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			};
		},
		methods: {
			handleCfy() {
				uni.request({
					url:"https://h5.mcake.com/api/5e90690f0e270d04?cityId=110",
					header:{
						"access-token": "49b6aa3aaf59e573a9d552b347480346",
						"version": "v1.0"
					},
					success:(res)=> {
						console.log(res)
						let{data}=res.data
						let batchobj = {"requests":[]}
						data.forEach(item=>{
							batchobj.requests.push({
								"method": "POST",
								"path": "/1.1/classes/classify",
								 "body": item
							})
						})
						this.$post('/1.1/batch',batchobj)
					}
				})

			},
			handleCGood(){
				uni.request({
					url:"https://h5.mcake.com/api/0434b49d1ac28f9d?cityId=110&page=2&bid=6",
					header:{
						"access-token": "49b6aa3aaf59e573a9d552b347480346",
						"version": "v1.0"
					},
					success:(res)=> {
						console.log(res)
						let{list}=res.data.data
						let batchobj = {"requests":[]}
						list.forEach(item=>{
							batchobj.requests.push({
								"method": "POST",
								"path": "/1.1/classes/goods",
								 "body": item
							})
						})
						this.$post('/1.1/batch',batchobj)
					}
				})
				
			}
		}
	}
</script>

<style lang="scss">

</style>
